package com.sys.utils;
public class Page2 {
	private int everyPage = 10; 
	private int totalCount; 
	private int totalPage; 
	private int currentPage = 1; 
	private int beginIndex = 0; 
	public Page2(int currentPage, int totalCount) { 
		this.currentPage = currentPage;
		this.beginIndex = (currentPage - 1) * everyPage; 
		if (totalCount <= everyPage) {
			this.totalPage = 1;
		} else {
			this.totalPage = (totalCount % everyPage) == 0 ? (totalCount / everyPage) : (totalCount / everyPage) + 1;
		}
	}
	public static Integer page(int currentPage, int everyPage) {
		return (currentPage - 1) * everyPage;
	}
	public static Integer totalPage(int totalCount, int everyPage) {
		if (totalCount <= everyPage) {
			return 1;
		} else {
			return (totalCount % everyPage) == 0 ? (totalCount / everyPage) : (totalCount / everyPage) + 1;
		}
	}
	public Page2() {
		super();
	}
	public Page2(int currentPage) { 
		this.currentPage = currentPage;
		this.beginIndex = (currentPage - 1) * everyPage; 
	}
	public static Integer everyPage(int everyPage, int totalPage, int totalCount) {
		if ((everyPage * totalPage) < totalCount) {
			if ((everyPage * totalPage) > (totalCount - everyPage)) {
				return totalCount - (everyPage * totalPage);
			}
		}
		return everyPage;
	}
	public int getEveryPage() {
		return everyPage;
	}
	public void setEveryPage(int everyPage) {
		this.everyPage = everyPage;
	}
	public int getTotalCount() {
		return totalCount;
	}
	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getBeginIndex() {
		return beginIndex;
	}
	public void setBeginIndex(int beginIndex) {
		this.beginIndex = beginIndex;
	}
}
